#pragma once

#include <string>
#include "mongoose.h"

using namespace std;

class IWebsocketClientCb
{
public:
    IWebsocketClientCb() {}
    virtual ~IWebsocketClientCb() {}
    virtual void onWsClientConnected() = 0;
    virtual void onWsClientReceiveMsg(string &msg) = 0;
    virtual void onWsClientClosed() = 0;
    virtual void onWsClientError() = 0;
};

class IWebsocketClient
{
public:
    IWebsocketClient(mg_mgr * = nullptr){}
    virtual ~IWebsocketClient(){}
    virtual bool connect(string url) = 0;
    virtual bool disconnect() = 0;
    virtual bool sendMsg(const string &msg) = 0;
    virtual void setListener(IWebsocketClientCb *listener) = 0;
    virtual bool run() = 0;
    virtual bool isConnected() = 0;
    virtual void setAutoReconnect(bool flag) = 0;
protected:
    string _url = "";
    IWebsocketClientCb *_listener = nullptr;
};

